{% extends 'user/base.html' %}
{% block user_index %}
    <div class="container">
        <div style="margin-top: 30px;">
            {#            {{ media }}#}
            <table class="table  table-striped" style="vertical-align: middle">
                <thead>
                <tr>
                    <th scope="col">序号</th>
                    <th scope="col">图片</th>
                    <th scope="col">题目</th>
                    <th scope="col">简介</th>
                    <th scope="col">时间</th>
                    <th scope="col">投票数量</th>
                    <th scope="col">操作</th>
                </tr>
                </thead>
                <tbody>
                {% for i in media %}
                    <tr>

                        <td>{{ forloop.counter }}</td>
                        <td>
                            <img src="{{ MEDIA_URL }}{{ i.photo }}" alt="{{ i.photo }}" height="60px" width="80px">

                        </td>
                        <td>{{ i.title }}</td>
                        <td>{{ i.synopsis }}</td>
                        <td>{{ i.time }}</td>
                        <td>{{ i.vote }}</td>
                        <td>
                            <a class="btn btn-sm btn-outline-primary" href="{% url 'media_edit' i.id %}">编辑</a>
                            <a class="btn btn-sm btn-outline-danger" data-bs-toggle="modal"
                               data-bs-target="#exampleModal-del{{ i.id }}" href="">删除</a>


                            <!-- Modal -->
                            <div class="modal fade" id="exampleModal-del{{ i.id }}" tabindex="-1"
                                 aria-labelledby="exampleModalLabel"
                                 aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">

                                            <div class="modal-header">
                                                <h5 class="modal-title" id="exampleModalLabel">请确认删除！</h5>
                                                <button type="button" class="btn-close" data-bs-dismiss="modal"
                                                        aria-label="Close"></button>
                                            </div>
                                            <div class="modal-body">
                                                确定删除“{{ i.title }}”吗？
                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
                                                    关闭
                                                </button>
                                                <a href="{% url 'media_del' i.id %}" class="btn btn-danger">确定</a>
                                            </div>

                                    </div>
                                </div>
                            </div>

                        </td>
                    </tr>
                {% empty %}
                    <h4 style="color: red">你还没有上传任何投票文件！！</h4>

                {% endfor %}


            </table>
            <div class="text-end">
                <a href="{% url 'media_add' %}" class="btn btn btn-primary">添加投票内容</a>
            </div>
        </div>
    </div>
{% endblock %}